package o;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;
import androidx.fragment.app.FragmentActivity;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol.Request;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import com.huawei.appmarket.framework.startevents.bean.FestivalCardBean;
import com.huawei.appmarket.service.exposure.bean.ExposureDetail;
import com.huawei.hms.support.api.entity.hwid.HwIDConstant.ACTION;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import java.lang.ref.WeakReference;
import java.util.LinkedHashMap;
import java.util.Timer;
import java.util.TimerTask;
import o.ewm.n;

public class ehr extends dif implements cyp {
    private static ehr ॱ = new ehr();
    private WeakReference<Activity> ˊ;
    private Timer ˋ = null;
    private cyo ˎ = ((cyo) fho.ˏ().ˋ("SplashScreen").ॱ(cyo.class));

    private ehr() {
        if (this.ˎ != null) {
            this.ˎ.ˎ(this);
        }
    }

    public static ehr ˏ() {
        return ॱ;
    }

    public void ˋ() {
        if (this.ˎ != null) {
            this.ˎ.ˋ();
        }
    }

    public void ˊ() {
        dgh.ˋ(ॱ(n.ʻᐝ), ʻ());
    }

    public void ˋ(String str, String str2, int i) {
        dgh.ˋ(ॱ(n.ʻˊ), ˊ(str, str2, -1, i));
    }

    public void ˋ(String str, String str2, long j, int i, String str3, String str4) {
        if (this.ˊ != null) {
            Activity activity = (Activity) this.ˊ.get();
        } else {
            Object obj = null;
        }
        if (activity != null) {
            ʼ();
            dgh.ˋ(ॱ(n.ﹳ), ˊ(str, str2, j, i));
            if (this.ˋ != null) {
                this.ˋ.cancel();
                this.ˋ = null;
            }
            ˏ(str);
            if (activity instanceof did) {
                ((did) activity).ʻॱ();
            }
            ˋ(activity, str, str3, str4, ˊ(str, str2, -1, i));
        }
    }

    private void ˋ(Activity activity, String str, String str2, String str3, LinkedHashMap<String, String> linkedHashMap) {
        String str4 = "Deeplink|";
        if (str.startsWith(str4)) {
            Logger.ˎ("SplashScreenWrapper", "deepLink=" + str);
            str4 = str.substring(str4.length());
            int indexOf = str4.indexOf(HiAnalyticsConstant.REPORT_VAL_SEPARATOR);
            if (indexOf > 0) {
                String substring = str4.substring(0, indexOf);
                String substring2 = str4.substring(indexOf + 1);
                if (substring2.length() <= 0) {
                    ˊ(linkedHashMap, "1");
                    return;
                } else if (((cdg) cdb.ॱ(cdg.class)).ॱॱ(substring)) {
                    try {
                        Intent intent = new Intent();
                        intent.setAction(ACTION.HWID_SCHEME_URL);
                        intent.setFlags(268435456);
                        intent.setPackage(substring);
                        intent.setData(Uri.parse(substring2));
                        activity.startActivity(intent);
                        if (str3 == null) {
                            str3 = "";
                        }
                        evk.ॱ(activity.getResources().getString(n.ˊᴵ, new Object[]{str3}), 0).ˋ();
                        ˎ(linkedHashMap, substring);
                        return;
                    } catch (Exception e) {
                        Logger.ˋ("SplashScreenWrapper", e.toString());
                        ˊ(linkedHashMap, "2");
                        return;
                    }
                } else {
                    ˋ(activity, str2);
                    ˏ(linkedHashMap, substring, str2);
                    return;
                }
            }
            ˊ(linkedHashMap, "1");
            return;
        }
        ˋ(activity, str);
    }

    private void ˋ(Activity activity, String str) {
        if (!TextUtils.isEmpty(str)) {
            BaseCardBean festivalCardBean = new FestivalCardBean();
            festivalCardBean.ॱ(str);
            festivalCardBean.isFromFestival = true;
            if (dgm.ˏ(activity)) {
                festivalCardBean.isFromGameBox = true;
            }
            if (!cii.ˊ().ˊ(activity, festivalCardBean)) {
                cjo appDetailActivityProtocol = new AppDetailActivityProtocol();
                appDetailActivityProtocol.ˏ(new Request(festivalCardBean.ॱॱ(), null));
                cjk.ˎ().ˋ(activity, new cjm("appdetail.activity", appDetailActivityProtocol));
            }
        }
    }

    public void ˋ(String str, String str2, long j, int i) {
        ˎ();
        dgh.ˋ(ॱ(n.ʻˋ), ˊ(str, str2, j, i));
        if (this.ˋ != null) {
            this.ˋ.cancel();
            this.ˋ = null;
        }
    }

    public void ˎ(String str, String str2, long j, int i) {
        ˎ();
        ॱ(str, str2, j, i);
        if (this.ˋ != null) {
            this.ˋ.cancel();
            this.ˋ = null;
        }
    }

    public void ॱ(final String str, String str2, int i) {
        if (this.ˋ != null) {
            this.ˋ.cancel();
            this.ˋ = null;
        }
        this.ˋ = new Timer();
        this.ˋ.schedule(new TimerTask(this) {
            final /* synthetic */ ehr ˊ;

            public void run() {
                this.ˊ.ˏ(str);
            }
        }, 1000);
    }

    public void ˎ(String str, String str2, int i) {
        if (this.ˋ != null) {
            this.ˋ.cancel();
            this.ˋ = null;
        }
    }

    public void ˋ(int i) {
        LinkedHashMap ʻ = ʻ();
        ʻ.put("cause", String.valueOf(i));
        dgh.ˋ(ॱ(n.ʼˊ), ʻ);
        if (this.ˋ != null) {
            this.ˋ.cancel();
            this.ˋ = null;
        }
    }

    private void ॱ(String str, String str2, long j, int i) {
        LinkedHashMap ˊ = ˊ(str, str2, -1, i);
        ˊ.put("timeout", String.valueOf(j));
        dgh.ˋ(ॱ(n.ʼˋ), ˊ);
    }

    protected boolean ˊ(boolean z) {
        return this.ˎ != null && this.ˎ.ˊ(z);
    }

    protected void ˊ(Activity activity) {
        if (activity instanceof FragmentActivity) {
            FragmentActivity fragmentActivity = (FragmentActivity) activity;
            fjm ˏ = fjm.ˏ(fiu.ˊ().ˋ(fragmentActivity, fho.ˏ().ˋ("SplashScreen").ˎ("SplashScreenFragment")));
            FragmentTransaction ˊ = fragmentActivity.ˏॱ().ˊ();
            ˊ.ˏ(16908290, ˏ.ˏ());
            ˊ.ˋ();
            this.ˊ = new WeakReference(fragmentActivity);
        }
    }

    public boolean ॱ() {
        return false;
    }

    private void ʼ() {
        if (ActivityUtil.ˎ()) {
            ActivityUtil.ॱ(true);
        }
    }

    public void ˎ() {
        Activity activity = this.ˊ != null ? (Activity) this.ˊ.get() : null;
        if (activity instanceof did) {
            ʼ();
            ((did) activity).ॱ("festivalimage");
        }
    }

    private String ॱ(int i) {
        return ContentManager.getInstant().getContext().getString(i);
    }

    private LinkedHashMap<String, String> ˊ(String str, String str2, long j, int i) {
        LinkedHashMap<String, String> ʻ = ʻ();
        ʻ.put("linkUrl", str);
        ʻ.put("id", str2);
        if (j > -1) {
            ʻ.put("clicktime", String.valueOf(j));
        }
        if (i >= 0) {
            ʻ.put("mediaType", String.valueOf(i));
        }
        return ʻ;
    }

    private LinkedHashMap<String, String> ʻ() {
        LinkedHashMap<String, String> linkedHashMap = new LinkedHashMap(5);
        linkedHashMap.put("region", eqp.ॱ());
        linkedHashMap.put("language", doi.ॱ());
        return linkedHashMap;
    }

    private void ˎ(LinkedHashMap<String, String> linkedHashMap, String str) {
        linkedHashMap.put("pkgName", str);
        dgh.ˋ(ॱ(n.ʹ), linkedHashMap);
    }

    private void ˊ(LinkedHashMap<String, String> linkedHashMap, String str) {
        linkedHashMap.put("errorCode", str);
        dgh.ˋ(ॱ(n.ꞌ), linkedHashMap);
    }

    private void ˏ(LinkedHashMap<String, String> linkedHashMap, String str, String str2) {
        linkedHashMap.put("pkgName", str);
        linkedHashMap.put("appDetailId", str2);
        dgh.ˋ(ॱ(n.ﾟ), linkedHashMap);
    }

    private void ˏ(String str) {
        Activity activity = this.ˊ != null ? (Activity) this.ˊ.get() : null;
        if (activity != null) {
            int ˎ = dgm.ˎ(activity);
            dyg ॱ = dyg.ॱ();
            ExposureDetail ˎ2 = ExposureDetail.ˎ(str);
            if (ˎ2 != null) {
                ˎ2.ˊ("splash screen");
                ॱ.ˎ(ˎ2, ˎ);
            }
            new dyf().ˊ(ॱ, ˎ);
        }
    }
}
